package services.api;

import java.util.HashMap;
import java.util.Map;

import dto.api.ApiAuthInfoDto;

import models.application.*;
import models.pubobj.AniHttpMethod;
import utils.*;

public class AniApiCallingService extends AniApiService {

	//-API authentication
	public static String callApiWithAppRel(ApiAuthInfoDto apiAuthInfo, Map<String, String> params){
		AniApi oneApi = AniApiAuthService.checkApiAuthInfoLegality(apiAuthInfo);
		AniApiAuthService.checkApiRequiredParams(oneApi, params);
		return callApiSync(oneApi, params);
	}
	//-call URL
	protected static String callApiSync(AniApi oneApi, Map<String, String> params){
		String targetUrl = oneApi.url;
		AniHttpMethod httpMethod = oneApi.method;
		return HttpUtils.callUrlSync(targetUrl, httpMethod.httpMethodKey, params);
	}
}
